<?php
/**
 * Datovy model uzivatela
 * @author Tomas Srna
 * @package bakalarka
 */
 
class UserModel extends Model
{
	protected function __construct()
	{
		$this->_table = 'user';
		$this->_fields = array(
			new Field('username', 'varchar(100)', true),
			new Field('password_hash', 'varchar(128)', false, true),
			new Field('email', 'varchar(100)'),
			new Field('group', 'varchar(100)'),
			new Field('firstname', 'varchar(50)', false, true),
			new Field('lastname', 'varchar(50)', false, true),
			new Field('phone', 'varchar(20)', false, true),
			new Field('address', 'varchar(200)', false, true)
		);
	}
	
	/**
	 * Kontrola hesla 
	 * (nie je mozne priamo porovnat kvoli hash funkcii)
	 */
	public function checkPassword($password)
	{
		return ($this->password_hash == 
			hash(Config::$hash_function, $password));
	}
}

